package com.example.service;

import com.example.entity.Post;
import com.example.entity.Questions;
import com.example.mapper.QuestionsMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
关卡任务业务处理
 */
@Service
public class QuestionsService {

    @Resource
    private QuestionsMapper questionsMapper;

    public void add(Questions questions) {
        questionsMapper.insert(questions);
    }

    public void deleteById(Integer id) {
        questionsMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(Questions questions) {
        questionsMapper.updateById(questions);
    }

    public Questions selectById(Integer id) {
        return questionsMapper.selectById(id);
    }

    public List<Questions> selectAll(Questions questions) {
        return questionsMapper.selectAll(questions);
    }

    public PageInfo<Questions> selectPage(Questions questions, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Questions> questionsList = questionsMapper.selectAll(questions);
        return PageInfo.of(questionsList);
    }
}
